package home_5_4;

import java.io.*;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Hash_file {
    public static void main(String[] args) throws  Exception {
        HashMap <Integer,String>  stu=new HashMap<Integer,String>();
        stu.put(1," 柯旭海");
        stu.put(2," 宋zj");
        stu.put(3," 何sq");
        stu.put(4," 陈yq");
        stu.put(5," 朱jy");
   BufferedWriter bu=new BufferedWriter(new FileWriter("D:\\a.txt"));



        Iterator iterator=(Iterator) stu.keySet().iterator();
        while (iterator.hasNext())
        {

//             获取每一个键
           Integer key=(Integer) iterator.next();
             String value=stu.get(key);
//             把建和值写入文件
            bu.write(key+value);
            bu.newLine();
            bu.flush();
        }
bu.close();




    }
}
